package com.nf.health.app.adapter;

import android.app.Activity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import com.nf.health.app.R;
import com.nf.health.app.customview.CircleImageView;
import com.nf.health.app.models.CommentVo;
import com.nf.health.app.utils.ImageLoaderUtils;
import com.nf.health.app.utils.Util;

import java.util.List;

/**
 * 健康方案  评论适配器
 * Created by Administrator on 2016/3/28.
 */
public class CommentAdapter extends BaseAdapter {

    private List<CommentVo> accounts;
    private Activity activity;

    public CommentAdapter(List<CommentVo> accounts,Activity activity) {
        this.accounts = accounts;
        this.activity = activity;
    }

    @Override
    public int getCount() {
        if(accounts != null){
            return accounts.size();
        }
        return 0;
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        ViewHolder holder = ViewHolder.get(parent, convertView, R.layout.item_comment, position);
        CommentVo account = accounts.get(position);

        CircleImageView iv_user_head_icon = holder.getView(R.id.comment_icon);

        String time = Util.timeStamp2Date(account.getCreatetime(),"yyyy-MM-dd");

        ImageLoaderUtils.getinstance(activity).getImage(iv_user_head_icon, account.getHimg(), R.drawable.default_head);
        holder.setText(R.id.comment_name, account.getNick());
        holder.setText(R.id.comment_value,account.getContent());//评论
        holder.setText(R.id.comment_time,time);
        return holder.getConvertView();
    }
}
